package com.kly.user.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.kly.user.db.dao.UserAccountsDao;
import com.kly.user.db.entity.UserAccessEntity;
import com.kly.user.db.entity.UserAccountsEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: yujianfu
 * Date: 2023-05-22
 * Time: 10:46:07.399
 */

@Repository
public class UserAccountsDaoImpl extends AbstractBaseMapper<UserAccountsEntity> implements UserAccountsDao {


    @Override
    public UserAccountsEntity selectByAccount(Map<String, Object> map) {
        return getSqlSession().selectOne(this.getStatement("selectByAccount"), map);
    }

    @Override
    public List<UserAccountsEntity> listByAccount(Map<String, Object> map) {
        return getSqlSession().selectList(this.getStatement("listByAccount"), map);
    }

    @Override
    public UserAccountsEntity selectByAccountByEmail(Map<String, Object> map) {
        return getSqlSession().selectOne(this.getStatement("selectByAccountByEmail"), map);
    }

    @Override
    public void deleteByUserCode(Map<String, Object> map) {
        getSqlSession().delete(this.getStatement("deleteByUserCode"), map);
    }

    @Override
    public void removeByUserCode(String userCode) {
        getSqlSession().delete(this.getStatement("removeByUserCode"), userCode);
    }


    @Override
    public List<UserAccountsEntity> getByUserCodes(List<String> useCodes) {
        Map<String, Object> params = new HashMap<>();
        params.put("useCodes", useCodes);
        return getSqlSession().selectList(this.getStatement("getByUserCodes"), params);
    }


    @Override
    public UserAccountsEntity getByUserCode(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectOne(this.getStatement("getByUserCode"), params);
    }
}